package com.txw.travel.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.txw.travel.bean.PermissionWithStatus;
import com.txw.travel.mapper.PermissionMapper;
import com.txw.travel.mapper.RoleMapper;
import com.txw.travel.pojo.Permission;
import com.txw.travel.pojo.Role;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Service
@Transactional//add tran
public class PermissionService {

    @Autowired
    private PermissionMapper permissionMapper;

    public Page<Permission> getPermissionList(Integer index, Integer size) {
        return permissionMapper.selectPage(new Page<Permission>(index, size), null);
    }

    public Permission getPermissionById(Integer pid) {
        return permissionMapper.selectById(pid);
    }

    public void insertPermission(Permission permission) {
        permissionMapper.insert(permission);
    }

    public void updatePermission(Permission permission) {
        permissionMapper.updateById(permission);
    }

    public void deletePermission(Integer pid) {
        permissionMapper.deleteById(pid);
    }
}
